import { defineStore } from 'pinia'

const useStore = defineStore('search',{
    state: () => ({
        originList: [
            {
                pid: 'w-001',
                ptime: '2022-01-10 22:00:00',
                paddr: '长沙 -- 北京',
                price: 1000
            },
            {
                pid: 'w-002',
                ptime: '2022-01-10 08:00:00',
                paddr: '长沙 -- 广州',
                price: 800
            },
            {
                pid: 'w-003',
                ptime: '2022-01-10 14:00:00',
                paddr: '长沙 -- 云南',
                price: 600
            }
        ],
        list: [],
    }),
    getters: {
        getList() {
            return this.list
        },
    },
    actions: {
        searchAction(Vprice){
            this.list = this.originList.filter(item => item.price >= Vprice)
        },
        initListAction(){
            this.list = [...this.originList]
        }
    }
})

export default useStore